// usb_wmDlg.h : header file
//


#pragma once
#include "stdafx.h"
#include "WmDrv.h"
#include "resource.h"


#define RCV_MSG				(WM_USER + 0x0800)
#define WM_UPDATEDATA   	(WM_USER + 0x0801)

class CWmDrv;
// Cusb_wmDlg dialog
class Cusb_wmDlg : public CDialog
{
// Construction
public:
	Cusb_wmDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_USB_WM_DIALOG };
	CListBox	m_wmMsgs;
	CWmDrv * 	m_pWmDrv ;
	bool			m_tmo;
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

public:
	HWND 			m_hwnd;

	void SetWMTimer(u32 tmo);
	void KillWMTimer();
	bool ChkWMTimer();
	void FreshItemNum();
	void FreshMsgList(char * str);
	
// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg   void   OnTimer(UINT   nIDEvent);	
	afx_msg void OnClose();	
	LRESULT OnUpdateData(WPARAM wParam, LPARAM lParam);	
	DECLARE_MESSAGE_MAP()
	BOOL OnDeviceChange(UINT nEventType, DWORD dwData);
	void AttemptConnection(void);

public:
	afx_msg void OnBnClickedOk();
public:
	afx_msg void OnBnClickedBtnClr();
public:
	afx_msg void OnBnClickedBtnStart();	
public:
	afx_msg void OnBnClickedBtnPasue();
public:
	afx_msg void OnBnClickedBtnReg();
public:
	afx_msg void OnBnClickedBtnAck();
public:
	afx_msg void OnBnClickedBtnSubData();
public:
	afx_msg void OnBnClickedBtnLast();
public:
	afx_msg void OnBnClickedBtnSetpara();

public:
	afx_msg void OnBnClickedBtnLogout();
private:
	u32 				m_rxad;
	u32 				m_txad;
	u32 				m_baud;
	u32 				m_RexMax;		/*Max number of register, 30 default*/
	u32				m_DataTmo;		/*data transfer time out*/
	u32				m_RegSlice;		/*register time out*/
	u32				m_DataSlice;		/*data time out*/
	u32			 	m_ClientSlice[3];	/*request chek tick for each client*/
	u32				m_RetryMax;	/*retry times in data transfer*/
	u32			 	m_ClientNum[3];
	u32 				m_serid;
	u32 				m_did;
	u32 				m_sid;
	CString 			m_data;
	u32				m_idle;			/*H->M time*/
	bool 			m_IsConnected;
	CString 			m_usbstatus;
	afx_msg void OnBnClickedBtnClrdata();
};
